package com.bravo.article.service;

import com.bravo.article.entity.Comment;
import com.bravo.article.repository.CommentRepository;
import com.bravo.common.util.IdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: Yuyong
 * @create: 2019-07-26 17:32
 **/

@Service
public class CommentService {

    @Autowired
    private CommentRepository commentRepository;

    @Autowired
    private IdWorker idWorker;

    public void add(Comment comment){
        comment.set_id(idWorker.nextId()+"");
        commentRepository.save(comment);
    }

    public List<Comment> findByArticleId(String articleId){
        return commentRepository.findByArticleId(articleId);
    }

}
